<template>
  <div class="mine bg">
    <img class="bg_img" src="@/assets/images/indexImg/top_banner.png">
    <div class="container">
      <img class="avatar" src="@/assets/images/touxiang.png">
      <!-- 申请中 待发货... -->
      <div class="change b f14">
        <div class="item" v-for="item in defaultChange" :key="item.path" @click="goOrder(item.path)">
          <img :src="item.imgUrl">
          <span class="title">
            {{ item.title }}
          </span>
        </div>
      </div>
      <!-- 领券中心 -->
      <img class="receive b" @click="goCoupon" src="@/assets/images/indexImg/000000.png">
      <!-- 我要买断 我要归坏... -->
      <div class="more b">
        <div class="item f14" v-for="(item, index) in moreChange" :key="index" @click="moreChangeHandle(item.path)">
          <img class="b" :src="item.imgUrl">
          <span class="title">
            {{ item.title }}
          </span>
        </div>
      </div>
      <!-- 为您推荐 -->
      <div class="recommend b">
        <img src="@/assets/images/recommend.png">
        <span>为您推荐</span>
      </div>
      <!-- 推荐的商品 -->
      <HomeWaterfall className="noPadding"></HomeWaterfall>
    </div>
  </div>
</template>
<script>
import { List } from 'vant';
import eventBus from "@/common/event-bus";
import HomeWaterfall from "@/components/Home/HomeWaterfall.vue";
import { defaultChange, moreChange } from "@/common/mineChangeList"
export default {
  name: "MineView",
  components: {
    HomeWaterfall,
    [List.name]: List,
  },
  data() {
    return {
      defaultChange,
      moreChange,
    }
  },
  created() {
    eventBus.$emit("correctPath", window.location.pathname);//NavigationBar.vue
  },
  methods: {
    goCoupon() {
      this.$router.push({ name: "coupon" })
    },
    goOrder(path) {
      this.$router.push({ name: "order", params: { path } })
    },
    moreChangeHandle(path) {
      if (typeof path == "number") {
        this.goOrder(path)
      } else {
        this.$router.push({ name: path })
      }
    },
    goGoods(id) {
      this.$router.push({ name: "goods", query: { id } })
    }
  }
}
</script>
<style lang="scss" scoped>
.bg_img {
  position: absolute;
  top: 0;
  left: 0;
  width: 375px;
}

.container {
  position: relative;
  z-index: 1000;
  padding: 15px;
  padding-bottom: 0;

  .avatar {
    width: 55px;
    border-radius: 50%;
    margin-bottom: 15px;
  }

  .change {
    border-radius: 10px;
    display: flex;
    background-color: white;
    padding: 15px;
    justify-content: space-between;

    .item {
      display: flex;
      flex-direction: column;
      align-items: center;

      img {
        width: 23px;
      }

      .title {
        margin-top: 10px;
      }
    }
  }

  .receive {
    width: 100%;
  }

  .more {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    background-color: white;

    .item {
      flex-basis: 33.3333%;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 10px;
      padding-top: 15px;
      border-bottom: 1px solid #f0f0f0;
      border-left: 1px solid #f0f0f0;

      &:last-of-type {
        border: 0;
      }

      &:nth-of-type(3n+1) {
        border-left: 0;
      }

      img {
        width: 30px;
      }
    }
  }

  .recommend {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 30px;
    margin-bottom: 20px;

    img {
      width: 20px;
      margin-right: 5px;
    }
  }
}
</style>